/*OS_SIM_H*/
#ifndef COMMON_TYPES_H
#define COMMON_TYPES_H

#ifdef __cplusplus
extern "C" {
#endif

#define IN 
#define OUT 
#define INOUT 


/* --- Common unsigned types ---------------------------------------------- */
typedef unsigned char    U8 ;
typedef unsigned short   U16;
typedef unsigned int     U32;
typedef unsigned long    UL32;

/* Common signed types */
//typedef signed char  S8;
typedef signed short S16;
typedef signed int   S32;
#ifndef BOOL
typedef int BOOL;
#endif

#ifndef TRUE
#define TRUE 1
#endif

#ifndef FALSE
#define FALSE 0
#endif



#if defined(WIN32)
typedef unsigned __int64 uint64_t;
typedef  __int64 int64_t;
#endif

#if defined(LINUX)
//typedef unsigned long long uint64_t;
//typedef  long long  int64_t;
#endif


typedef  uint64_t U64;
typedef  int64_t  S64;

typedef  int64_t mtime_t;

//typedef  unsigned char uint8_t;
//typedef  unsigned short uint16_t;
//typedef  unsigned int  uint32_t;


#define VAR_FOURCC( a, b, c, d ) \
        ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \
           | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
#define VAR_TWOCC( a, b ) \
        ( (uint16_t)(a) | ( (uint16_t)(b) << 8 ) )






#ifdef WIN32
#endif

#ifdef LINUX
#endif


#ifndef FALSE
#define FALSE 0
#define TRUE  1
#endif


#ifndef BIT
#define BIT(b) (1<<(b))
#endif

#define CYCLIC_DISTANCE(From,To,BuffSize)   ((From)<=(To)) ? ((To)-(From)) : ( (To) - (From)  + (BuffSize))  

#define POINTER_DISTANCE(From,To,BuffSize)  ((From)<(To)) ? ((To)-(From))  :  ( (To) - (From) + (BuffSize))  

#if !defined(min)
#define min(a,b) (((a) <= (b)) ? (a ) : (b))
#endif

#if !defined(max)
#define max(a,b) (((a) > (b)) ? (a ) : (b))
#endif


/*****************************************************************************
 * Error values (shouldn't be exposed)
 *****************************************************************************/
#define RET_SUCCESS         -0                                   /* No error */
#define RET_ENOMEM          -1                          /* Not enough memory */
#define RET_ETHREAD         -2                               /* Thread error */
#define RET_ETIMEOUT        -3                                    /* Timeout */

#define RET_ENOMOD         -10                           /* Module not found */

#define RET_ENOOBJ         -20                           /* Object not found */

#define RET_ENOVAR         -30                         /* Variable not found */
#define RET_EBADVAR        -31                         /* Bad variable value */

#define RET_ENOITEM        -40                           /**< Item not found */

#define RET_EEXIT         -255                             /* Program exited */
#define RET_EEXITSUCCESS  -999                /* Program exited successfully */
#define RET_EGENERIC      -666                              /* Generic error */





#ifdef __cplusplus
}
#endif

#endif

